package com.wxmp.market.zhuli.service.impl;

import com.wxmp.market.zhuli.domain.WxZhuliBaseInfo;
import com.wxmp.market.zhuli.mapper.WxZhuliBaseInfoDao;
import com.wxmp.market.zhuli.service.WxZhuliBaseInfoService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;

@Service("zhuliBaseService")
public class WxZhuliBaseInfoServiceImpl implements WxZhuliBaseInfoService {

    @Resource
    private WxZhuliBaseInfoDao baseInfoDao;

    @Override
    public List<WxZhuliBaseInfo> getAvailableActivityByConfig() {
        //我要获取当前的日期
        Date date = new Date();
        //设置要获取到什么样的时间
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //获取String类型的时间
        String currentDate = sdf.format(date);
        return baseInfoDao.selectAvailableList(currentDate);
    }

    @Override
    public String scanActivityByQRCode() {
        return null;
    }

    @Override
    public List<WxZhuliBaseInfo> getActivityListByPage(WxZhuliBaseInfo searchEntity) {
        return baseInfoDao.getActivityListByPage(searchEntity);
    }

    /**
     * 根据活动入口二维码查询活动信息
     *
     * @param baseCode
     * @return
     */
    @Override
    public WxZhuliBaseInfo selectByBaseCode(String baseCode) {
        return baseInfoDao.selectByBaseCode(baseCode);
    }

    @Override
    public WxZhuliBaseInfo selectByQRCode(String QRCode) {
        return baseInfoDao.selectByQRCode(QRCode);
    }

    @Override
    public void add(WxZhuliBaseInfo baseInfo) {
        baseInfoDao.add(baseInfo);
    }

    @Override
    public void update(WxZhuliBaseInfo baseInfo) {
        baseInfoDao.update(baseInfo);
    }

    //@Override
    public String scanActivityByQRCode(String appId, String openId, String qrCode) {
        return "";
    }
}
